package com.jiyun.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiyun.pojo.goods.Ad;
import com.jiyun.service.goods.AdService;
import com.jiyun.service.goods.CategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller // RestController返回值json，要使用thymeleaf不能使用json
public class IndexController {

    @Reference
    AdService adService;
    @Reference
    CategoryService categoryService;

    @RequestMapping("/index")
//    @GetMapping("/index")// 只能接收get请求
//    @PostMapping("/index")// 只能接收post请求
    public String index(Model model){

        // 轮播图
        List<Ad> list = adService.findByPosition("web_index_lb");
        model.addAttribute("lbt",list);

        // 菜单
        List<Map> categoryList =categoryService.findCategoryTree();
        model.addAttribute("categoryList",categoryList);
        return "index";
    }

}
